<?php
class Mwc_SystemPoint_Model_Membership extends Mage_Core_Model_Abstract{
    protected function _construct(){
        $this->_init('systempoint/membership');
    }

    public function getMembershipId(){
        return $this->getId();
    }
    
	public function getTitle(){
	        return $this->_getData('title');
	}
	
	public function getNumberOfPoint(){
	        return $this->_getData('number_of_point');
	}
	
	public function getPercentDiscount(){
	        return $this->_getData('percent_discount');
	}
	
	public function getIconPath(){
	        return $this->_getData('icon_path');
	}

	public function loadByPoint($point){
		//$model = Mage::getModel('systempoint/membership');
        $member = $this->getCollection()->addFieldToFilter('number_of_point', array('lteq' => $point))        
        			->addOrder('number_of_point','DESC')
        			->setPageSize(1);
        $pnt[]='';
	    foreach($member as $item){
            $pnt['title'] = $item->getTitle();
            $pnt['number_of_point'] = $item->getNumberOfPoint();
            $pnt['percent_discount'] = $item->getPercentDiscount();
            $pnt['icon_path'] = $item->getIconPath();
        }
        return $pnt;
	}
	
	public function loadHighestPoint(){
		//$model = Mage::getModel('systempoint/membership');
        $member = $this->getCollection()        
        			->addOrder('number_of_point','DESC')
        			->setPageSize(1);
        $pnt[]='';
	    foreach($member as $item){
            $pnt['title'] = $item->getTitle();
            $pnt['number_of_point'] = $item->getNumberOfPoint();
            $pnt['percent_discount'] = $item->getPercentDiscount();
            $pnt['icon_path'] = $item->getIconPath();
        }
        return $pnt;
	}
}